package course.exception;

public class ExceptionTest {
    public static void main(String[] args) {
        int [] arr = null;
        try {
            printArr(arr);
        } catch (Exception e) {
            System.out.println("参数不能为null");
        }

        System.out.println("这个代码也可以执行");
    }

    private static void printArr(int[] arr) {
        if(arr == null){
            throw new NullPointerException();
        }else{
            for (int i = 0; i < arr.length; i++) {
                System.out.println(arr[i]);
            }
        }
    }
}
